package com.java.thread.demo.chapter1.suspend;

/**
 * Created by yiyongyao on 2017/12/19.
 */
public class MyThread extends Thread {


    private long i = 0;

    public long getI() {
        return i;
    }

    public void setI(long i) {
        this.i = i;
    }


    @Override
    public void run() {
        try {
            while (true) {
                if (this.interrupted()) {

                    System.out.println("子线程已经停止,我准备退出!");
                    throw new InterruptedException();
                } else {
                    i++;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
